Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On delete account screen, add account number validation during input #5069

Conversation

rablador
Copy link
Contributor

@rablador rablador commented Aug 30, 2023

When entering the last 4 digits of the account number on the account deletion screen, the OK button lights up even if the number is incorrect. When pressing the OK button an error message is displayed, saying that the number is indeed incorrect. The process has now been simplified by having the OK button itself function as validation instead and only enabling it if input is valid.


This change is Reviewable

@rablador rablador added the iOS Issues related to iOS label Aug 30, 2023
@linear
Copy link

linear bot commented Aug 30, 2023

IOS-278 Account deletion view enables OK button even if number is wrong

When entering the last 4 digits of the account number on the account deletion screen, the OK button lights up even if the number is incorrect. When pressing the OK button an error message is displayed, saying that the number is indeed incorrect. We could simplify this process by having the OK button function as validation instead and only enabling it if input is valid.

@rablador rablador force-pushed the account-deletion-view-enables-ok-button-even-if-number-is-ios-278 branch from 4c1f369 to 9cc7a43 Compare August 30, 2023 13:52
Comment on lines +256 to +267
let inputLengthIsValid = input.count == 4
let inputMatchesAccountNumber = accountNumber.suffix(4) == input

return inputLengthIsValid && inputMatchesAccountNumber
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is inputLengthIsValid really needed?

accountNumber.suffix(4) == input seems to imply that input is indeed 4 characters long when it matches accountNumber.suffix(4)... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The param in .suffix() specifies a max length, meaning the result could be less than that. In practice the account number - if present - should never be less than 4 digits, so for most (or perhaps all realistic) cases it should work as intended.
Theoretically though, accountNumber.suffix(4) could for some reason return something less than 4 digits, and if so the condition would be incorrect (eg. 3 digit account number matching 3 digit input). It's a safeguard, but perhaps it's not really necessary...

Copy link
Contributor

@MrChocolatine MrChocolatine Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice the account number - if present - should never be less than 4 digits

Yep this is what I assumed that'shy. But okay 👍 sorry for the bother!

@@ -326,7 +335,7 @@ class AccountDeletionContentView: UIView {
} else {
activityIndicator.stopAnimating()
}
deleteButton.isEnabled = isDeleteButtonEnabled && isAccountNumberLengthSatisfied
deleteButton.isEnabled = isDeleteButtonEnabled && isInputValid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should isDeleteButtonEnabled be updated too?

Currently it still says the button should be enabled upon failure:

private var isDeleteButtonEnabled: Bool {
switch state {
case .initial, .failure:
return true
case .loading:
return false
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to disable the button when loading (to avoid interaction while trying to delete the account), otherwise enabled.

Copy link
Collaborator

@mojganii mojganii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @MrChocolatine)

Copy link
Contributor

@pronebird pronebird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @MrChocolatine)

@rablador rablador force-pushed the account-deletion-view-enables-ok-button-even-if-number-is-ios-278 branch from 9cc7a43 to 39e1eab Compare September 11, 2023 14:31
@pinkisemils pinkisemils force-pushed the account-deletion-view-enables-ok-button-even-if-number-is-ios-278 branch from 39e1eab to 1c9a3b0 Compare September 11, 2023 15:05
@pinkisemils pinkisemils merged commit 97c9771 into main Sep 11, 2023
@pinkisemils pinkisemils deleted the account-deletion-view-enables-ok-button-even-if-number-is-ios-278 branch September 11, 2023 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issues related to iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants